package com.hui.service.impl;


import com.hui.bean.RecordBean;
import com.hui.dao.impl.RecordDaoImpl;
import com.hui.service.IRecordService;

import java.sql.SQLException;
import java.util.List;

/**
 * 检修记录业务层实现类
 *
 */
public class RecordServiceImpl implements IRecordService {

    private RecordDaoImpl recordDao;

    public RecordServiceImpl(){
        try {
            recordDao=RecordDaoImpl.class.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    @Override
    public boolean addRecord(RecordBean recordBean, int roomId) {
        try {
            return recordDao.saveRecord(recordBean, roomId)==1;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public boolean processRecord(int recordId, int roomId) {
        try {
            return recordDao.updateRecord(recordId, roomId)==1;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }

    }

    @Override
    public List<RecordBean> getRecordBeanListByRoomId(int roomId) {
        try {
            return recordDao.getAllRecordsByRoomId(roomId);
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public int getRecordStatusIsZeroAccountByRoomId(int roomId) {

        return 0;
    }
}
